﻿
using System;
using System.Collections.Generic;
using System.Text;

using YouHP.Utility;
using YouHP.BLL;
using YouHP.Model;
using YouHP.Model.Group;

namespace YouHP.Pages.BBS
{
    public class BoardBasePage : YouHP.Pages.BasePage
    {
        protected override void ShowPage()
        {
            base.ShowPage();
            if (ErrorCount > 0) return;

            HandleCommon();
        }
        protected GroupInfo GroupData;
        protected string[] moderators;
        protected int[] moderatorsId;

        //版块的帖子种类列表
        protected List<string> TopicSortList = new List<string>();

        protected void HandleCommon()
        {
            this.SetTitle("论坛");
            this.AddLocation("论坛", "/BBS/Index.aspx");

            int gid = RequestTools.GetInt("gid", 0);
            if (gid <= 0)
            {
                this.AddErrLine("无效的参数 gid ！");
                return;
            }

            GroupData = GroupBLL.Instance.GetGroupInfo(gid);
            if (GroupData.Id <= 0)
            {
                this.AddErrLine("该版块不存在！");
                return;
            }
            this.AddLocation(GroupData.GroupName, "/BBS/Board.aspx?gid="+GroupData.Id);

            //获取版主信息
            string[] array = GroupData.Moderators.Split('@');
            if (array.Length != 0)
            {
                List<int> moderatorIds = new List<int>();
                List<string> moderatorNames = new List<string>();

                for (int i = 0; i < array.Length; i++)
                {
                    string[] array2 = array[i].Split(';');

                    moderatorNames.Add(array2[0]);
                    moderatorIds.Add(Convert.ToInt32(array2[1]));
                }
                moderators = moderatorNames.ToArray();
                moderatorsId = moderatorIds.ToArray();

            }

            //获取版块帖子分类清单
            string[] TopicSortArray = GroupData.TopicSortString.Split('@');
            for(int i=0;i<TopicSortArray.Length;i++)
            {
                TopicSortList.Add(TopicSortArray[i]);
            }


        }

    }
}